package com.dckeji.shiplock.webapp.controller.rest;

import com.dckeji.shiplock.webapp.controller.BaseController;
import com.dckeji.shiplock.webapp.pojo.LogicRsult;
import com.dckeji.shiplock.webapp.pojo.TimeOutApply;
import com.dckeji.shiplock.webapp.service.ITimeOutApplyService;
import com.dckeji.shiplock.webapp.util.ReturnMsgUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: TianWei
 * Date: 2017/8/9
 * Time: 10:45
 * 过号延时
 */
@RestController
@RequestMapping("/rest/toa/")
public class TimeOutApplyController extends BaseController {
    @Autowired
    ITimeOutApplyService timeOutApplyService;

    @RequestMapping("commit")
    public LogicRsult timeOutApply(TimeOutApply timeOutApply) {
        int row = timeOutApplyService.timeOutApply(timeOutApply);
        if (row > 0) {
            return ReturnMsgUtil.success();
        } else {
            return ReturnMsgUtil.sysError();
        }
    }

    @RequestMapping("queryAll")
    public LogicRsult queryTimeOutApplyList() {
        List<TimeOutApply> timeOutApplies = timeOutApplyService.queryTimeOutApplyList();
        if (null != timeOutApplies && timeOutApplies.size() > 0) {
            return ReturnMsgUtil.success(timeOutApplies);
        } else {
            return ReturnMsgUtil.notData();
        }
    }
}
